<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    letn1, n2 = 123, n3 = null, n4 = true, n5 = 'hello', n6 = '', n7 = 0;
    console.log(Boolean(n1));   //将未定义转为布尔型
    console.log(Boolean(n2));   //非0数值转布尔型
    console.log(Boolean(n3));   //null转布尔型
    console.log(Boolean(n5));   //非空字符转布尔
    console.log(Boolean(n6));   //空字符串转布尔
    console.log(Boolean(n7));   //0转布尔型
    //未定义、null 、空字符串 、0 转为 字符串 结果为false
    //非0数值 和 非空字符 转 布尔型 结果为true
    console.log('---------');
    console.log(Number(n6));
    console.log(parseInt(n6));
    console.log(parseFloat(n6));
    let num = parseInt(n6);
    console.log(num);
    console.log(typeof(n6));
    console.log(Boolean(num));
   
</script>
</html>